﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CNotebook;
using CNotebook.Purchases;

namespace NotebookS2.Purchases.Logs
{
    public partial class LOGS_SVCRCPT : Form
    {
        public LOGS_SVCRCPT()
        {
            InitializeComponent();
        }

        public string ConnectionString { get; set; }

        private void BindGrid()
        {
            ServiceReceiptManager oManager = new ServiceReceiptManager();
            DataTable dt = new DataTable();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            dt = oManager.GetServiceReceiptHeadersByPostingDate(Convert.ToDateTime(dtFROM.EditValue), Convert.ToDateTime(dtTO.EditValue),
                    chkDraft.Checked, chkPosted.Checked, chkOpen.Checked, chkClosed.Checked);

            oManager.Close();

            gridControl1.DataSource = dt;
            gridControl1.Refresh();
            
        }

        private void LOGS_ServiceReceipt_Load(object sender, EventArgs e)
        {
            dtFROM.EditValue = System.DateTime.Now.ToShortDateString();
            dtTO.EditValue = System.DateTime.Now.ToShortDateString();
        }

        private void btnPreview_Click(object sender, EventArgs e)
        {
            DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(typeof(WaitForm3));
            BindGrid();
            DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
        }
    }
}
